﻿using DAO.DAOUtils;
using DTO.BaseDTO;
using DTO.DTOUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO.BaseDAO
{
    public class PersonDAO
    {
        public PersonDTO Insert(PersonDTO person)
        {
            List<Parameter> listParam = GetListParamNoneId(person);
            Parameter output = new Parameter(DTOConstant.PersonId, person.Id);
            SQLUtils.ExcuteNoneQuery("PersonInsert", ref listParam, ref output);
            person.Id = output.Value.ToString();
            return person;
        }

        public List<Parameter> GetListParamNoneId(PersonDTO person)
        {
            List<Parameter> listParam = new List<Parameter>();

            listParam.Add(new Parameter(DTOConstant.PersonName, person.PersonName));
            listParam.Add(new Parameter(DTOConstant.PersonGender, person.PersonGender));
            listParam.Add(new Parameter(DTOConstant.PersonDateOfBirt, person.PersonDateOfBirt));
            listParam.Add(new Parameter(DTOConstant.PersonCVFile, person.PersonCVFile));
            listParam.Add(new Parameter(DTOConstant.AddressIdCurr, person.AddressCurr.AddressId));
            listParam.Add(new Parameter(DTOConstant.AddressIdBirt, person.AddressBirt.AddressId));

            return listParam;
        }
    }
}
